package com.yzd.netmonitor.util;

/**
 * 正则表达式匹配规则.
 */
public final class RegexHelper {

	/** 手机号规则 */
	private static final String REG_MOBILE = "^1[3|5|7|8|][0-9]{9}$";
	
	private static final String REG_MAIL = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
	
	/**
	 * 验证是否为手机号.
	 * @param mobile	手机号.
	 * @return
	 */
	public static boolean isMobileNumber(final String mobile) {
		if (Check.NuNString(mobile)) {
			return false;
		}
		return mobile.matches(REG_MOBILE);
	}
	
	public static boolean  isMail(final String mail) {
		if (Check.NuNString(mail)) {
			return false;
		}
		return mail.matches(REG_MAIL);
	}
	
	private RegexHelper() {
		throw new AssertionError("Uninstantiable class.");
	}
	
	public static void main(String[] args) {
		System.out.println(isMail("lipeng@kokozu.net"));
	}
}
